[T4Scaffolding.Scaffolder(Description = "Enter a description of ListViewModel here")][CmdletBinding()]
param(        
    [parameter(Mandatory = $true)][string]$ModelType,
    
    [string]$Project, # this must remain there because of T4Scaffolding logic
    
    [parameter(Mandatory = $true)][string]$FrontendProject,
    [parameter(Mandatory = $true)][string]$CommonProject,
    
	[string]$CodeLanguage,
	[string[]]$TemplateFolders,
	[switch]$Force = $false
)

# find type of model class
$foundModelType = Get-ProjectType $ModelType -Project $CommonProject -BlockUi
if (!$foundModelType) { return }

# name and its plural of model class
$modelTypeName = $foundModelType.Name
$modelTypePluralized = Get-PluralizedWord $modelTypeName

# name of primary key 
$primaryKeyName = [string](Get-PrimaryKey $foundModelType.FullName -Project $CommonProject -ErrorIfNotFound)
if (!$primaryKeyName) { return }

$outputPath = Join-Path "Views" ($modelTypeName +"ListView")  # The filename extension will be added based on the template's <#@ Output Extension="..." #> directive
$frontendNamespace = (Get-Project $FrontendProject).Properties.Item("DefaultNamespace").Value

$model = @{ 
    FrontendNamespace = $frontendNamespace; 
    ModelType = [MarshalByRefObject]$foundModelType ;
    PrimaryKeyName = $primaryKeyName;
    
    ModelTypePluralized = [string]$modelTypePluralized; 
    };

Add-ProjectItemViaTemplate $outputPath -Template ListViewTemplate `
	-Model $model `
	-SuccessMessage "Added ListView output at {0}" `
	-TemplateFolders $TemplateFolders -Project $FrontendProject -CodeLanguage $CodeLanguage -Force:$Force